package org.springblade.modules.platform.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.platform.entity.MeasuringChainPlatformInfo;
import org.springblade.modules.platform.mapper.MeasuringChainPlatformInfoMapper;
import org.springblade.modules.platform.service.IMeasuringChainPlatformInfoService;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author SYG
 * @since 2023-07-10
 */
@Service
public class MeasuringChainPlatformInfoServiceImpl extends ServiceImpl<MeasuringChainPlatformInfoMapper, MeasuringChainPlatformInfo> implements IMeasuringChainPlatformInfoService {

    @Override
    public List<MeasuringChainPlatformInfo> getMeasuringChainPlatformInfo(Long measuringTypeId) {
        List<MeasuringChainPlatformInfo> measuringChainPlatformInfos = baseMapper.selectList(Wrappers.<MeasuringChainPlatformInfo>query().lambda().eq(MeasuringChainPlatformInfo::getMeasuringTypeId, measuringTypeId));
        if(Func.isEmpty(measuringChainPlatformInfos)){
            return null;
        }
        return measuringChainPlatformInfos.stream().sorted(Comparator.comparing(MeasuringChainPlatformInfo::getSort)).collect(Collectors.toList());
    }
}
